package largestPerimeter;

import java.util.Arrays;

public class Solution {
    public int largestPerimeter(int[] nums) {
        Arrays.sort(nums);
        for (int i = nums.length-1; i >= 0; i--) {
            for (int j = i+1; j>=0; j--) {
                for (int k = j+1; k >= 0; k--) {
                    if(check(nums[i],nums[j],nums[k])){
                        return nums[i] + nums[j] + nums[k];
                    }
                }
            }
        }
        return 0;
    }
    private boolean check(int a,int b,int c){
        return a < b + c;
    }
}
